import java.util.Scanner;

class Employee 
{
	private int id;  // instance variables
	private String name; 
    private double salary;
		
	public Employee(int id, String name, double salary) // constructor
	{
		this.id = id;
		this.name = name;
		this.salary = salary;
	}
	
	public Employee(String name, int id, double salary) // constructor
	{
		this(id,name,salary);
		
	 }
	
	public Employee(int id, String name) // constructor
	{
		this(id, name, 0.0);
	}
	public Employee(String name, int id) // constructor
	{
		this(id, name, 0.0);
	}
	
	public void setSalary(double salary) // method
	{
		this.salary = salary;
    }
    
    public int getID() //method 
	{
      return id;
    }
   
     public String getName() // method
	{
    	return name;
     }
   
     public double getSalary() // method
	{
    	return salary;
     }
   			
	public void deductions(double telephoneBills) throws IllegalArgumentException
	{ 
       if(telephoneBills <= 0)
          throw new IllegalArgumentException("Error: Invalid telephoneBill amount");
       else
	     salary -= telephoneBills;
	 }
 
	public void deductions(double telephoneBills, double medicalBills) 
          throws IllegalArgumentException {
         if(telephoneBills <= 0 || medicalBills <= 0)
             throw new IllegalArgumentException("Error: Invalid bill amount");
         else
	       salary -= (telephoneBills + medicalBills);
     }
   
	public void raiseSalary(double percentIncrease) throws IllegalArgumentException
	{
          if(percentIncrease <= 0)
              throw new IllegalArgumentException("Error: Invalid percentIncrease");
           else
	          salary += salary * percentIncrease/100;
	}
	
	public String toString() // method
	{
	   return "\nID: " + id + "\nName: " + name+"\nSalary: "+salary + " SAR";
	}

    public boolean equals(Object obj){
        if(obj == null)
           return false;
        else if(this.getClass() != obj.getClass())
        	return false;
        else{
           Employee employee = (Employee) obj;
           return this.id == employee.id;
        }
   }
} // end of class
 
//The following shows how the constructors and the overloaded methods
// in the above example may be used:
 
public class EmployeeDriver
{
	public static void main(String[] args)
            {
		Scanner  scanner = new Scanner(System.in);
		int number;
		String name;
		double salary;
		System.out.print("Enter Name for Employee 1: ");
		name = scanner.nextLine();
		
		System.out.print("Enter ID Number for Employee 1: ");
		number = scanner.nextInt();
		
		System.out.print("Enter Salary for Employee 1 (> 100): ");
		salary = scanner.nextDouble();

		scanner.nextLine();   // skip new line character
		//any of the following constructors be used to create the object
		Employee emp1 = new Employee (number, name, salary);
// or                Employee emp1 = new Employee (name, number, salary);		
		System.out.print("\nEnter Name for Employee 2: ");
		name = scanner.nextLine();
		
		System.out.print("Enter ID Number for Employee 2: ");
		number = scanner.nextInt();
		
		//if we do not know the salary, we can use one of the following constructors
		Employee emp2 = new Employee (number, name);
//or	            Employee emp2 = new Employee (name, number);
 
		emp2.setSalary(emp1.getSalary()); // set the salary of employee2 to be equal to that of employee1
		
		emp1.deductions(50);
		emp2.deductions(60, 40);
		System.out.println(emp1);
		System.out.println(emp2);
 
	} // end of main method		
} // end of class
